#include <Ogre.h>

#include "PauseState.h"
#include "PlayState.h"

using namespace Ogre;

PauseState PauseState::mPauseState;

void PauseState::enter()
{
	mDeviceManager = DeviceManager::getSingletonPtr();
	mKeyboard = mDeviceManager->mKeyboard;
	mMouse = mDeviceManager->mMouse;
	mDeviceManager->setBuffered(true);

	mRoot = Root::getSingletonPtr();

	mViewport = mRoot->getAutoCreatedWindow()->getViewport(0);
	mViewport->setBackgroundColour(ColourValue(0.0, 1.0, 0.0));
}

void PauseState::exit()
{
}

void PauseState::pause()
{
}

void PauseState::resume()
{
}

bool PauseState::keyPressed(const OIS::KeyEvent &arg)
{
	if (arg.key == OIS::KC_TAB)
	{
		popState();
	}
	return true;
}

bool PauseState::keyReleased(const OIS::KeyEvent &arg)
{
	return true;
}

bool PauseState::mouseMoved( const OIS::MouseEvent &arg )
{
	//CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
	return true;
}

bool PauseState::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
	//CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
	return true;
}

bool PauseState::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
	//CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
	return true;
}

bool PauseState::frameStarted(const FrameEvent& evt)
{	
	if (mKeyboard) 
		mKeyboard->capture();
	if (mMouse)
		mMouse->capture();
	return true;
}

bool PauseState::frameEnded(const FrameEvent& evt)
{
	return true;
}